var pageii = null;

var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "equipmentName",
			name : "设备名称"
		},{
			colkey : "equipmentSpecification",
			name : "设备规格"
		},{
			colkey : "equipmentModel",
			name : "设备型号"
		},{
			colkey : "installDate",
			name : "安装日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		},{
			colkey : "position",
			name : "安装地点"
		},{
			colkey : "supplier",
			name : "供应商名称"
		},{
			colkey : "usedTime",
			name : "已使用的时间"
		},{
			colkey : "price",
			name : "价格"
		}
		,{
			colkey : "remark",
			name : "备注",
		
		},{
			colkey : "fillPeopleId",
			name : "填报人"
		},{
			colkey : "status",
			name : "状态"
		},{
			colkey : "operation",
			name : "操作"
		},],
		jsonUrl : rootPath + '/equip/equip_abolishByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	
	$("#editFun").click("click", function() {
		
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑订单",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/equip/abolish_edit.shtml?id=' + cbox
	});
}
function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/equip/abolish_delEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}


